refactor: Improve http error messages#1294
Conversation
73a559a to
d1bc6e8
Compare
| return "HTTP status code: 500 - Internal Server Error"; | ||
| default: return "HTTP status code"; | ||
| } | ||
| } |
There was a problem hiding this comment.
I wonder if it would be possible to print to a string with something like this:
"HTTP status code: %d - %s", code, some_message
But I cannot find an easy solution.
There was a problem hiding this comment.
yep, no easy solution, if we want to create dynamic strings.
we could refactor to use heap segment instead of data segment, but this would imply in refactoring and also, making the callers responsible to free.
we could have a global buffer variable and just update this buffer when this function its called, however, this might cause race condition bugs.
Simple solution and the "correct" for this use case, would be having a big switch statement to handle all the possible status code.
I wrote only I few, cause I am pretty sure that these are the common ones.
There was a problem hiding this comment.
I don't think this part of the code is used by multiple threads, but I don't like the idea of code that is not thread-safe any way. So let's merge this as is. However, could you fix the CI issues first?
You can run tests/lint/run.sh locally.
Tried to connect to a new vpn today.
However, my user was not allowed to connect.
The logs were not useful, it was only showing
Http Status Code.So, I did this little change, just as logging improvement
I also added the status code description after I took this screenshot